<template>
  <div class="orderContainer">
    <div class="titleBox">
      <div class="title">
        我的退换货
      </div>
    </div>
    <div class="orderBox">
      <div class="header">
        <div
          v-for="(item, index) in statuList"
          :key="item.status"
          class="title"
          :class="{ active: tabIndex == index }"
          @click="selectedIndex(item, index)"
        >
          {{ item.title }}
        </div>
      </div>
      <div class="searchBox">
        <div class="searchInfo">
          <el-form
            :inline="true"
            :model="formInline"
            :label-position="labelPosition"
            label-width="80px"
            class="demo-form-inline"
          >
            <div>
              <el-form-item label="退货单号">
                <el-input
                  v-model="formInline.searchSaleReturnNo"
                  placeholder="输入退货单号查询"
                  class="selectAddress"
                  style="width: 19.38rem"
                />
              </el-form-item>
            </div>
            <div>
              <el-form-item label="订单编号">
                <el-input
                  v-model="formInline.searchOrderNo"
                  placeholder="输入订单编号"
                  class="selectAddress"
                  style="width: 19.38rem"
                />
              </el-form-item>
            </div>
            <div>
              <el-form-item label="申请时间">
                <el-date-picker
                  v-model="formInline.searchTimer"
                  type="daterange"
                  align="right"
                  unlink-panels
                  range-separator="-"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  style="width: 19.38rem"
                  :picker-options="pickerOptions"
                  value-format="yyyy-MM-dd"
                />
              </el-form-item>
            </div>
          </el-form>
        </div>
        <div
          class="searchBtn"
          @click="SearchClick"
        >
          搜索
        </div>
      </div>
    </div>
    <orderList
      ref="Search"
      :status="statusName"
      @goDetail="goDetail"
      @delOrder="delOrder"
    />
    <!-- <PageNation /> -->
  </div>
</template>

<script>
import orderList from "../../components/order/Returnlist.vue";
// import PageNation from "../../components/common/page_nation.vue";
export default {
  components: {
    orderList,
    // PageNation,
  },
  data() {
    return {
      // 订单状态 
       // “” (全部); 
       // “SUBMITSALERETURN” (待审批); 
       // “CONFIRMSALERETURNORDER” (待退货); 
       // “BUYERRETURN” (待退款) ; 
       // “ENDSALERETURN” (已完成); 
       // “OPPOSESALERETURN” (已驳回)
      statuList: [
        {
          status: 0,
          title: "全部订单",
          statusName: "",
        },
        {
          status: 1,
          title: "待审批",
          nums: 0,
          statusName: "SUBMITSALERETURN",
        },
        {
          status: 2,
          title: "待退货",
          nums: 0,
          statusName: "CONFIRMSALERETURNORDER",
        },
        {
          status: 3,
          title: "待退款",
          nums: 0,
          statusName: "BUYERRETURN",
        },
        {
          status: 4,
          title: "已完成",
          nums: 0,
          statusName: "ENDSALERETURN",
        },
        {
          status: 5,
          title: "已驳回",
          nums: 0,
          statusName: "OPPOSESALERETURN",
        },
      ],
      dataList: [{}, {}, {}, {}, {}],
      tabIndex: 0,
      statusName: "",
      labelPosition: "right",
      formInline: {
        searchSaleReturnNo: "", // 退货单号
        searchOrderNo: "", // 订单编号
        searchTimer: [], // 申请时间
      },
      pageIndex: 1,
      pageSize: 10,
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      timer: "",
      payMoney: 0,
    };
  },
  mounted() {
  },
  methods: {
    //选择状态
    selectedIndex(item, index) {
      this.statusName = item.statusName;
      this.tabIndex = index;
      this.formInline = {
        searchSaleReturnNo: "", // 退货单号
        searchOrderNo: "", // 订单编号
        searchTimer: [], // 申请时间
      }
    },
    //跳转详情
    goDetail() {
      this.$router.push({
        path: "/person/orderDetail",
        params: {
          goods: 1,
        },
      });
    },
    // 搜索
    SearchClick() {
      console.log('搜索',this.formInline)
      this.$refs.Search.SearchObj(this.formInline)
    }
  },
};
</script>

<style scoped lang="scss">
.orderContainer {
  .titleBox {
    display: flex;
    flex-direction: row;
    padding: 2.75rem 2.63rem 0 2.63rem;
    align-items: center;
    background: #fff;

    .title {
      font-size: 1.13rem;
      color: #333;
    }
  }
  .orderBox {
    background-color: #fff;
    padding: 1.31rem 1.75rem 0;

    .header {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      border-bottom: 0.06rem solid rgba(216, 216, 216, 1);

      .title {
        cursor: pointer;
        font-size: 1.25rem;
        padding: 0.63rem 0.94rem;
        position: relative;

        .nums {
          position: absolute;
          right: -0.5rem;
          top: 0;
          width: 1.38rem;
          height: 1.38rem;
          text-align: center;
          line-height: 1.38rem;
          background: #f0406f;
          border-radius: 50%;
          color: #fff;
          font-size: 1rem;
        }

        &.active {
          color: #f0406f;
          position: relative;
          padding: 0.63rem 0.94rem;
          border-bottom: 0.31rem solid rgba(240, 64, 111, 1);
        }
      }
    }

    .searchBox {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      padding: 1.63rem 0 0;
      align-items: flex-start;

      .searchInfo {
        .el-form {
          display: flex;
          flex-direction: row;
          flex-wrap: wrap;

          > div {

            &:nth-child(2n) {
              margin-right: 0;
            }
          }
        }
      }

      .searchBtn {
        width: 3.69rem;
        font-size: 0.88rem;
        padding: 0.7rem;
        color: #fff;
        text-align: center;
        background: rgba(0, 0, 0, 1);
        border: 0px solid rgba(0, 0, 0, 1);
        border-radius: 0.2rem;
        cursor: pointer;

        &:hover {
          opacity: 0.7;
        }
      }
    }
  }
}
</style>
